package com.sean.service;

import com.sean.dao.StudentMapper;
import com.sean.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;


@Service("studentServiceImpl")
public class StudentServiceImpl implements StudentService {


    @Autowired
    private StudentMapper studentMapper;

    @Override
    @Transactional(propagation = Propagation.REQUIRED)   //加了transcational表明这个方法里的操作是同一个事物,由spring管理,同生同灭,有error就全部回滚
    public int createStudent(Student student) {
        studentMapper.insertSelective(student);
        return 0;
    }
}
